/*
 * Tests of IEEE 754 single-precision multiplication
 *
 * Copyright (c) 1999-2025, Arm Limited.
 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
 */

#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

struct test
{
  uint32_t in1, in2, out;
};

static const struct test tests[] = {
  // Tests that don't depend on Arm-specific NaN policy
  { 0x00000000, 0x00000000, 0x00000000 },
  { 0x00000000, 0x007fffff, 0x00000000 },
  { 0x00000000, 0x00ffffff, 0x00000000 },
  { 0x00000000, 0x3f800000, 0x00000000 },
  { 0x00000000, 0x7effffff, 0x00000000 },
  { 0x00000000, 0x80000000, 0x80000000 },
  { 0x00000000, 0x80000002, 0x80000000 },
  { 0x00000000, 0x807fffff, 0x80000000 },
  { 0x00000000, 0x80800001, 0x80000000 },
  { 0x00000000, 0x81000000, 0x80000000 },
  { 0x00000000, 0xc0400000, 0x80000000 },
  { 0x00000000, 0xfe7fffff, 0x80000000 },
  { 0x00000000, 0xff000000, 0x80000000 },
  { 0x00000000, 0xff7fffff, 0x80000000 },
  { 0x00000001, 0x00000000, 0x00000000 },
  { 0x00000001, 0x00000001, 0x00000000 },
  { 0x00000001, 0x3f000000, 0x00000000 },
  { 0x00000001, 0x3f7fffff, 0x00000001 },
  { 0x00000001, 0x3f800000, 0x00000001 },
  { 0x00000001, 0x40000000, 0x00000002 },
  { 0x00000001, 0x7f800000, 0x7f800000 },
  { 0x00000001, 0xbf7fffff, 0x80000001 },
  { 0x00000006, 0x3f000000, 0x00000003 },
  { 0x00000006, 0xbf000000, 0x80000003 },
  { 0x00000008, 0x3e000000, 0x00000001 },
  { 0x007ffff7, 0x81000003, 0x80000000 },
  { 0x007ffff8, 0x3f800001, 0x007ffff9 },
  { 0x007ffff8, 0x3f800008, 0x00800000 },
  { 0x007ffff8, 0xbf800001, 0x807ffff9 },
  { 0x007ffff8, 0xbf800008, 0x80800000 },
  { 0x007ffffc, 0x40000000, 0x00fffff8 },
  { 0x007ffffe, 0x3f7ffffc, 0x007ffffc },
  { 0x007ffffe, 0x3f800001, 0x007fffff },
  { 0x007ffffe, 0xbf800001, 0x807fffff },
  { 0x007fffff, 0x007ffffe, 0x00000000 },
  { 0x007fffff, 0x3f800001, 0x00800000 },
  { 0x007fffff, 0x40000000, 0x00fffffe },
  { 0x00800000, 0x00000000, 0x00000000 },
  { 0x00800000, 0x00800000, 0x00000000 },
  { 0x00800000, 0x3f7ffffe, 0x007fffff },
  { 0x00800000, 0x7f800000, 0x7f800000 },
  { 0x00800000, 0x80800000, 0x80000000 },
  { 0x00800000, 0xc0000000, 0x81000000 },
  { 0x00800001, 0x3f7ffffa, 0x007ffffe },
  { 0x00800001, 0x3f7ffffe, 0x00800000 },
  { 0x00800001, 0xc0000000, 0x81000001 },
  { 0x00800002, 0x3f7ffffc, 0x00800000 },
  { 0x00fffff8, 0x3f000000, 0x007ffffc },
  { 0x00fffffe, 0x3f000000, 0x007fffff },
  { 0x00fffffe, 0xbf000000, 0x807fffff },
  { 0x00ffffff, 0x3f000000, 0x00800000 },
  { 0x00ffffff, 0xbf000000, 0x80800000 },
  { 0x3f000000, 0x80000001, 0x80000000 },
  { 0x3f800000, 0x007ffffd, 0x007ffffd },
  { 0x3f800000, 0x01000003, 0x01000003 },
  { 0x3f800000, 0x3f800000, 0x3f800000 },
  { 0x3f800000, 0x40000000, 0x40000000 },
  { 0x3f800000, 0x80000001, 0x80000001 },
  { 0x3f800000, 0x80000009, 0x80000009 },
  { 0x3f800001, 0x3f800001, 0x3f800002 },
  { 0x3f800001, 0xbf800001, 0xbf800002 },
  { 0x3f800001, 0xbf800002, 0xbf800003 },
  { 0x3f800002, 0x3f800001, 0x3f800003 },
  { 0x3f800002, 0x7f7ffffe, 0x7f800000 },
  { 0x3f800001, 0x7f7ffffe, 0x7f800000 },
  { 0x40000000, 0x00800000, 0x01000000 },
  { 0x40000000, 0x00800001, 0x01000001 },
  { 0x40000000, 0x3f800000, 0x40000000 },
  { 0x40000000, 0x40400000, 0x40c00000 },
  { 0x40000000, 0x7e800000, 0x7f000000 },
  { 0x40000000, 0x7effffff, 0x7f7fffff },
  { 0x40000000, 0x807ffffd, 0x80fffffa },
  { 0x40000000, 0x80800003, 0x81000003 },
  { 0x40000000, 0x80800005, 0x81000005 },
  { 0x40000000, 0xbf800000, 0xc0000000 },
  { 0x40000000, 0xfe7ffffd, 0xfefffffd },
  { 0x40000000, 0xfe800003, 0xff000003 },
  { 0x403fffff, 0x3f7ffffd, 0x403ffffd },
  { 0x403fffff, 0x3f7ffffe, 0x403ffffe },
  { 0x403fffff, 0x3f7fffff, 0x403ffffe },
  { 0x403fffff, 0xbf7ffffd, 0xc03ffffd },
  { 0x40400000, 0x00000002, 0x00000006 },
  { 0x40400000, 0x40000000, 0x40c00000 },
  { 0x40400000, 0x40400000, 0x41100000 },
  { 0x40400000, 0xc0000000, 0xc0c00000 },
  { 0x40400001, 0x3f800001, 0x40400003 },
  { 0x40400001, 0x3f800003, 0x40400006 },
  { 0x40400001, 0xbf800003, 0xc0400006 },
  { 0x40800000, 0x00000002, 0x00000008 },
  { 0x40800000, 0x7e7fffff, 0x7f7fffff },
  { 0x40800000, 0xfe7fffff, 0xff7fffff },
  { 0x409fffff, 0x3f7fffff, 0x409ffffe },
  { 0x40a00000, 0x00000000, 0x00000000 },
  { 0x40a00000, 0x7f800000, 0x7f800000 },
  { 0x40a00001, 0x3f800001, 0x40a00002 },
  { 0x40dfffff, 0x3f7ffffc, 0x40dffffc },
  { 0x40dfffff, 0x3f7fffff, 0x40dffffe },
  { 0x40e00000, 0x80000000, 0x80000000 },
  { 0x40e00000, 0xff800000, 0xff800000 },
  { 0x40e00001, 0x3f800001, 0x40e00003 },
  { 0x7e7ffffd, 0x40800000, 0x7f7ffffd },
  { 0x7e7ffffd, 0xc0800000, 0xff7ffffd },
  { 0x7e800000, 0xc0000000, 0xff000000 },
  { 0x7efffffd, 0xc0000008, 0xff800000 },
  { 0x7effffff, 0xc0000000, 0xff7fffff },
  { 0x7f000000, 0x00000000, 0x00000000 },
  { 0x7f000000, 0x40000000, 0x7f800000 },
  { 0x7f000000, 0x7f000000, 0x7f800000 },
  { 0x7f000000, 0x7f7ffffe, 0x7f800000 },
  { 0x7f000000, 0x7f800000, 0x7f800000 },
  { 0x7f000000, 0xfe800000, 0xff800000 },
  { 0x7f000000, 0xfe800004, 0xff800000 },
  { 0x7f000000, 0xff000000, 0xff800000 },
  { 0x7f000009, 0x7f7ffffa, 0x7f800000 },
  { 0x7f000009, 0xc0c00002, 0xff800000 },
  { 0x7f7fffff, 0x00000000, 0x00000000 },
  { 0x7f800000, 0x007fffff, 0x7f800000 },
  { 0x7f800000, 0x00ffffff, 0x7f800000 },
  { 0x7f800000, 0x3f800000, 0x7f800000 },
  { 0x7f800000, 0x7effffff, 0x7f800000 },
  { 0x7f800000, 0x7f800000, 0x7f800000 },
  { 0x7f800000, 0x80000002, 0xff800000 },
  { 0x7f800000, 0x807fffff, 0xff800000 },
  { 0x7f800000, 0x80800001, 0xff800000 },
  { 0x7f800000, 0x81000000, 0xff800000 },
  { 0x7f800000, 0xc0400000, 0xff800000 },
  { 0x7f800000, 0xff000000, 0xff800000 },
  { 0x7f800000, 0xff7fffff, 0xff800000 },
  { 0x7f800000, 0xff800000, 0xff800000 },
  { 0x80000000, 0x00000000, 0x80000000 },
  { 0x80000000, 0x40c00000, 0x80000000 },
  { 0x80000000, 0x7f7fffff, 0x80000000 },
  { 0x80000000, 0x80000000, 0x00000000 },
  { 0x80000000, 0x80000004, 0x00000000 },
  { 0x80000000, 0x80800000, 0x00000000 },
  { 0x80000000, 0xc1000000, 0x00000000 },
  { 0x80000000, 0xfe800000, 0x00000000 },
  { 0x80000001, 0x00000001, 0x80000000 },
  { 0x80000001, 0x40a00000, 0x80000005 },
  { 0x80000002, 0x3f800000, 0x80000002 },
  { 0x80000003, 0x00000000, 0x80000000 },
  { 0x80000003, 0x7f800000, 0xff800000 },
  { 0x80000004, 0xbf800000, 0x00000004 },
  { 0x80000008, 0x3e000000, 0x80000001 },
  { 0x807ffff7, 0x01000003, 0x80000000 },
  { 0x807ffff7, 0x3f800001, 0x807ffff8 },
  { 0x807ffffd, 0xc0000000, 0x00fffffa },
  { 0x807fffff, 0x00000000, 0x80000000 },
  { 0x807fffff, 0x3f800001, 0x80800000 },
  { 0x807fffff, 0x7f800000, 0xff800000 },
  { 0x807fffff, 0x80000000, 0x00000000 },
  { 0x807fffff, 0x807ffffe, 0x00000000 },
  { 0x807fffff, 0xbf800000, 0x007fffff },
  { 0x807fffff, 0xff800000, 0x7f800000 },
  { 0x80800000, 0x00800000, 0x80000000 },
  { 0x80800000, 0x80800000, 0x00000000 },
  { 0x80800001, 0x00000000, 0x80000000 },
  { 0x80800001, 0x7f800000, 0xff800000 },
  { 0x80800001, 0xbf800000, 0x00800001 },
  { 0x80fffffc, 0x3f000000, 0x807ffffe },
  { 0x80fffffc, 0xbf000000, 0x007ffffe },
  { 0x80fffffe, 0x3f800000, 0x80fffffe },
  { 0x80ffffff, 0x80000000, 0x00000000 },
  { 0x80ffffff, 0xff800000, 0x7f800000 },
  { 0x81000000, 0x00000000, 0x80000000 },
  { 0x81000000, 0x7f800000, 0xff800000 },
  { 0xbf7fffff, 0xff7fffff, 0x7f7ffffe },
  { 0xbf800000, 0x00000009, 0x80000009 },
  { 0xbf800000, 0x00800009, 0x80800009 },
  { 0xbf800000, 0x3f800000, 0xbf800000 },
  { 0xbf800000, 0x40000000, 0xc0000000 },
  { 0xbf800000, 0xbf800000, 0x3f800000 },
  { 0xbf800000, 0xc0000000, 0x40000000 },
  { 0xbf800001, 0x3f800001, 0xbf800002 },
  { 0xbf800001, 0xbf800001, 0x3f800002 },
  { 0xbf800001, 0xbf800002, 0x3f800003 },
  { 0xbf800002, 0x3f800001, 0xbf800003 },
  { 0xbf800002, 0xbf800001, 0x3f800003 },
  { 0xc0000000, 0x00000000, 0x80000000 },
  { 0xc0000000, 0x007ffffd, 0x80fffffa },
  { 0xc0000000, 0x00800001, 0x81000001 },
  { 0xc0000000, 0x00800005, 0x81000005 },
  { 0xc0000000, 0x00800009, 0x81000009 },
  { 0xc0000000, 0x40400000, 0xc0c00000 },
  { 0xc0000000, 0x7e7fffff, 0xfeffffff },
  { 0xc0000000, 0x7e800001, 0xff000001 },
  { 0xc0000000, 0x7f800000, 0xff800000 },
  { 0xc0000000, 0xbf800000, 0x40000000 },
  { 0xc0000000, 0xc0400000, 0x40c00000 },
  { 0xc03ffffe, 0x7f000000, 0xff800000 },
  { 0xc03fffff, 0x3f7fffff, 0xc03ffffe },
  { 0xc0400000, 0x40400000, 0xc1100000 },
  { 0xc0400000, 0xc0000000, 0x40c00000 },
  { 0xc0400000, 0xc0400000, 0x41100000 },
  { 0xc0400000, 0xff000000, 0x7f800000 },
  { 0xc0400001, 0x3f800001, 0xc0400003 },
  { 0xc0800000, 0x7e7fffff, 0xff7fffff },
  { 0xc0800000, 0x80000000, 0x00000000 },
  { 0xc0800000, 0xfe7fffff, 0x7f7fffff },
  { 0xc0800000, 0xff800000, 0x7f800000 },
  { 0xc09ffffe, 0xff000000, 0x7f800000 },
  { 0xc09fffff, 0xbf7fffff, 0x409ffffe },
  { 0xc0a00001, 0xbf800001, 0x40a00002 },
  { 0xc0dffff9, 0x7f000000, 0xff800000 },
  { 0xc1100000, 0x7f000000, 0xff800000 },
  { 0xc1100001, 0xff000000, 0x7f800000 },
  { 0xfe7ffff9, 0x7f000000, 0xff800000 },
  { 0xfe7ffff9, 0xc07fffff, 0x7f7ffff8 },
  { 0xfe7ffffd, 0x40800000, 0xff7ffffd },
  { 0xfe7ffffd, 0xc0800000, 0x7f7ffffd },
  { 0xfe7fffff, 0x00000000, 0x80000000 },
  { 0xfe7fffff, 0x40000001, 0xff000000 },
  { 0xfe7fffff, 0x7f800000, 0xff800000 },
  { 0xfe800000, 0x00000000, 0x80000000 },
  { 0xfe800000, 0x7f800000, 0xff800000 },
  { 0xfefffff7, 0x7e800001, 0xff800000 },
  { 0xfeffffff, 0x3f800001, 0xff000000 },
  { 0xfeffffff, 0x80000000, 0x00000000 },
  { 0xff000005, 0xff000001, 0x7f800000 },
  { 0xff7ffffd, 0x7f000000, 0xff800000 },
  { 0xff7ffffd, 0xc0400001, 0x7f800000 },
  { 0xff7ffffd, 0xff000001, 0x7f800000 },
  { 0xff7fffff, 0x80000000, 0x00000000 },
  { 0xff7fffff, 0xff7fffff, 0x7f800000 },
  { 0xff7fffff, 0xff800000, 0x7f800000 },
  { 0xff800000, 0x40c00000, 0xff800000 },
  { 0xff800000, 0x7f800000, 0xff800000 },
  { 0xff800000, 0x80000004, 0x7f800000 },
  { 0xff800000, 0x80800000, 0x7f800000 },
  { 0xff800000, 0xc1000000, 0x7f800000 },
  { 0xff800000, 0xfe800000, 0x7f800000 },
  { 0xff800000, 0xff800000, 0x7f800000 },
  { 0x3089705f, 0x0ef36390, 0x0041558f },
  { 0x3089705f, 0x0e936390, 0x0027907d },
  { 0x3109705f, 0x0ef36390, 0x0082ab1e },
  { 0x3109705f, 0x0e936390, 0x004f20fa },
  { 0x3189705f, 0x0ef36390, 0x0102ab1e },
  { 0x3189705f, 0x0e936390, 0x009e41f5 },
  { 0xb089705f, 0x0ef36390, 0x8041558f },
  { 0xb089705f, 0x0e936390, 0x8027907d },
  { 0xb109705f, 0x0ef36390, 0x8082ab1e },
  { 0xb109705f, 0x0e936390, 0x804f20fa },
  { 0xb189705f, 0x0ef36390, 0x8102ab1e },
  { 0xb189705f, 0x0e936390, 0x809e41f5 },
  { 0x3089705f, 0x8ef36390, 0x8041558f },
  { 0x3089705f, 0x8e936390, 0x8027907d },
  { 0x3109705f, 0x8ef36390, 0x8082ab1e },
  { 0x3109705f, 0x8e936390, 0x804f20fa },
  { 0x3189705f, 0x8ef36390, 0x8102ab1e },
  { 0x3189705f, 0x8e936390, 0x809e41f5 },
  { 0xb089705f, 0x8ef36390, 0x0041558f },
  { 0xb089705f, 0x8e936390, 0x0027907d },
  { 0xb109705f, 0x8ef36390, 0x0082ab1e },
  { 0xb109705f, 0x8e936390, 0x004f20fa },
  { 0xb189705f, 0x8ef36390, 0x0102ab1e },
  { 0xb189705f, 0x8e936390, 0x009e41f5 },
  { 0x1f800001, 0x1fc00000, 0x00300000 },
  { 0x1f800003, 0x1fc00000, 0x00300001 },
  { 0x1f800001, 0x1fc00800, 0x00300200 },
  { 0x1f800003, 0x1fc00800, 0x00300201 },
  { 0x36e4588a, 0x29b47cbd, 0x2120fd85 },
  { 0x3fea3b26, 0x3f400000, 0x3fafac5c },
  { 0x6fea3b26, 0x4f400000, 0x7f800000 },
  { 0x20ea3b26, 0x1ec00000, 0x0057d62e },
  { 0x3f8f11bb, 0x3fc00000, 0x3fd69a98 },
  { 0x6f8f11bb, 0x4fc00000, 0x7f800000 },
  { 0x208f11bb, 0x1f400000, 0x006b4d4c },
  { 0x3f8f11bb, 0x3f800000, 0x3f8f11bb },
  { 0x6f8f11bb, 0x4f800000, 0x7f800000 },
  { 0x208f11bb, 0x1f000000, 0x004788de },
  { 0x3f8f11bb, 0x3fd7f48d, 0x3ff1611f },
  { 0x6f8f11bb, 0x4fd7f48d, 0x7f800000 },
  { 0x208f11bb, 0x1f57f48d, 0x0078b090 },
  { 0x3f8f11bb, 0x3fa80b73, 0x3fbbd412 },
  { 0x6f8f11bb, 0x4fa80b73, 0x7f800000 },
  { 0x208f11bb, 0x1f280b73, 0x005dea09 },
  { 0x3f8f11bb, 0x3f97f48d, 0x3fa9d842 },
  { 0x6f8f11bb, 0x4f97f48d, 0x7f800000 },
  { 0x208f11bb, 0x1f17f48d, 0x0054ec21 },
  { 0x3f8f11bb, 0x3f680b73, 0x3f81ae78 },
  { 0x6f8f11bb, 0x4f680b73, 0x7f800000 },
  { 0x208f11bb, 0x1ee80b73, 0x0040d73c },
  { 0x3fff5dd8, 0x3f600000, 0x3fdf721d },
  { 0x6fff5dd8, 0x4f600000, 0x7f800000 },
  { 0x20ff5dd8, 0x1ee00000, 0x006fb90e },
  { 0x3fff5dd8, 0x3f100000, 0x3f8fa4ca },
  { 0x6fff5dd8, 0x4f100000, 0x7f800000 },
  { 0x20ff5dd8, 0x1e900000, 0x0047d265 },
  { 0x3fffe96b, 0x3f7efb43, 0x3ffee4c5 },
  { 0x6fffe96b, 0x4f7efb43, 0x7f800000 },
  { 0x20ffe96b, 0x1efefb43, 0x007f7263 },
  { 0x3fffe96b, 0x3f0104bd, 0x3f80f95b },
  { 0x6fffe96b, 0x4f0104bd, 0x7f800000 },
  { 0x20ffe96b, 0x1e8104bd, 0x00407cae },
  { 0x3f8fbbb7, 0x3fa6edf9, 0x3fbb72aa },
  { 0x6f8fbbb7, 0x4fa6edf9, 0x7f800000 },
  { 0x208fbbb7, 0x1f26edf9, 0x005db955 },
  { 0x3f8fbbb7, 0x3fd91207, 0x3ff3c07b },
  { 0x6f8fbbb7, 0x4fd91207, 0x7f800000 },
  { 0x208fbbb7, 0x1f591207, 0x0079e03d },
  { 0x3f8fbbb7, 0x3f991207, 0x3fabe29f },
  { 0x6f8fbbb7, 0x4f991207, 0x7f800000 },
  { 0x208fbbb7, 0x1f191207, 0x0055f150 },
  { 0x3f8fbbb7, 0x3f66edf9, 0x3f81a843 },
  { 0x6f8fbbb7, 0x4f66edf9, 0x7f800000 },
  { 0x208fbbb7, 0x1ee6edf9, 0x0040d421 },
  { 0x3fdb62f3, 0x3f7879c5, 0x3fd4f036 },
  { 0x6fdb62f3, 0x4f7879c5, 0x7f800000 },
  { 0x20db62f3, 0x1ef879c5, 0x006a781b },
  { 0x3faaea45, 0x3f8b6773, 0x3fba2489 },
  { 0x6faaea45, 0x4f8b6773, 0x7f800000 },
  { 0x20aaea45, 0x1f0b6773, 0x005d1244 },
  { 0x3fafa7ec, 0x3f900000, 0x3fc59cea },
  { 0x6fafa7ec, 0x4f900000, 0x7f800000 },
  { 0x20afa7ec, 0x1f100000, 0x0062ce75 },
  { 0x3fcf8c8d, 0x3f271645, 0x3f8776be },
  { 0x6fcf8c8d, 0x4f271645, 0x7f800000 },
  { 0x20cf8c8d, 0x1ea71645, 0x0043bb5f },
  { 0x3fc173ef, 0x3f901b0f, 0x3fd9cb52 },
  { 0x6fc173ef, 0x4f901b0f, 0x7f800000 },
  { 0x20c173ef, 0x1f101b0f, 0x006ce5a9 },
  { 0x3fb48d33, 0x3f4a35fb, 0x3f8e9d7d },
  { 0x6fb48d33, 0x4f4a35fb, 0x7f800000 },
  { 0x20b48d33, 0x1eca35fb, 0x00474ebe },
  { 0x3fc6f87b, 0x3f65d94d, 0x3fb2a52a },
  { 0x6fc6f87b, 0x4f65d94d, 0x7f800000 },
  { 0x20c6f87b, 0x1ee5d94d, 0x00595295 },
  { 0x3f860ae7, 0x3f969729, 0x3f9db312 },
  { 0x6f860ae7, 0x4f969729, 0x7f800000 },
  { 0x20860ae7, 0x1f169729, 0x004ed989 },
  { 0x3f860ae7, 0x3fc00000, 0x3fc9105a },
  { 0x6f860ae7, 0x4fc00000, 0x7f800000 },
  { 0x20860ae7, 0x1f400000, 0x0064882d },
  { 0x3f860ae7, 0x3fe968d7, 0x3ff46da3 },
  { 0x6f860ae7, 0x4fe968d7, 0x7f800000 },
  { 0x20860ae7, 0x1f6968d7, 0x007a36d1 },
  { 0x3f860ae7, 0x3f800000, 0x3f860ae7 },
  { 0x6f860ae7, 0x4f800000, 0x7f800000 },
  { 0x20860ae7, 0x1f000000, 0x00430574 },
  { 0x3f860ae7, 0x3fa968d7, 0x3fb1682f },
  { 0x6f860ae7, 0x4fa968d7, 0x7f800000 },
  { 0x20860ae7, 0x1f2968d7, 0x0058b418 },
  { 0x3f860ae7, 0x3fd69729, 0x3fe0b886 },
  { 0x6f860ae7, 0x4fd69729, 0x7f800000 },
  { 0x20860ae7, 0x1f569729, 0x00705c43 },
  { 0x3f9aecdd, 0x3fb14b75, 0x3fd696de },
  { 0x6f9aecdd, 0x4fb14b75, 0x7f800000 },
  { 0x209aecdd, 0x1f314b75, 0x006b4b6f },
  { 0x3f9aecdd, 0x3fceb48b, 0x3ffa2fb9 },
  { 0x6f9aecdd, 0x4fceb48b, 0x7f800000 },
  { 0x209aecdd, 0x1f4eb48b, 0x007d17dc },
  { 0x3f9aecdd, 0x3fc00000, 0x3fe8634c },
  { 0x6f9aecdd, 0x4fc00000, 0x7f800000 },
  { 0x209aecdd, 0x1f400000, 0x007431a6 },
  { 0x3fd65dc6, 0x3f400000, 0x3fa0c654 },
  { 0x6fd65dc6, 0x4f400000, 0x7f800000 },
  { 0x20d65dc6, 0x1ec00000, 0x0050632a },
  { 0x3feecf03, 0x3f5f93ab, 0x3fd09014 },
  { 0x6feecf03, 0x4f5f93ab, 0x7f800000 },
  { 0x20eecf03, 0x1edf93ab, 0x0068480a },
  { 0x3feecf03, 0x3f206c55, 0x3f95a670 },
  { 0x6feecf03, 0x4f206c55, 0x7f800000 },
  { 0x20eecf03, 0x1ea06c55, 0x004ad338 },
  { 0x3f98feed, 0x3f60f11b, 0x3f866f27 },
  { 0x6f98feed, 0x4f60f11b, 0x7f800000 },
  { 0x2098feed, 0x1ee0f11b, 0x00433794 },
  { 0x3f9a1b9d, 0x3f9c42b5, 0x3fbc21f8 },
  { 0x6f9a1b9d, 0x4f9c42b5, 0x7f800000 },
  { 0x209a1b9d, 0x1f1c42b5, 0x005e10fc },
  { 0x3f9a1b9d, 0x3f5c42b5, 0x3f8497e3 },
  { 0x6f9a1b9d, 0x4f5c42b5, 0x7f800000 },
  { 0x209a1b9d, 0x1edc42b5, 0x00424bf2 },
  { 0x3f947044, 0x3f600000, 0x3f81e23c },
  { 0x6f947044, 0x4f600000, 0x7f800000 },
  { 0x20947044, 0x1ee00000, 0x0040f11e },
  { 0x3fa3fb77, 0x3f6eb1b9, 0x3f98e5a0 },
  { 0x6fa3fb77, 0x4f6eb1b9, 0x7f800000 },
  { 0x20a3fb77, 0x1eeeb1b9, 0x004c72d0 },
  { 0x3fb291df, 0x3f466a1f, 0x3f8a66d9 },
  { 0x6fb291df, 0x4f466a1f, 0x7f800000 },
  { 0x20b291df, 0x1ec66a1f, 0x0045336c },
  { 0x3fde13d5, 0x3f6b7283, 0x3fcc3f8b },
  { 0x6fde13d5, 0x4f6b7283, 0x7f800000 },
  { 0x20de13d5, 0x1eeb7283, 0x00661fc5 },
  { 0x3fd5b211, 0x3f80810f, 0x3fd68987 },
  { 0x6fd5b211, 0x4f80810f, 0x7f800000 },
  { 0x20d5b211, 0x1f00810f, 0x006b44c4 },
  { 0x3fd5b211, 0x3f3f7ef1, 0x3f9fd9d2 },
  { 0x6fd5b211, 0x4f3f7ef1, 0x7f800000 },
  { 0x20d5b211, 0x1ebf7ef1, 0x004fece9 },
  { 0x3fadfbc4, 0x3f400000, 0x3f827cd3 },
  { 0x6fadfbc4, 0x4f400000, 0x7f800000 },
  { 0x20adfbc4, 0x1ec00000, 0x00413e6a },
  { 0x3fd0ef03, 0x3f800000, 0x3fd0ef03 },
  { 0x6fd0ef03, 0x4f800000, 0x7f800000 },
  { 0x20d0ef03, 0x1f000000, 0x00687782 },
  { 0x3fd0ef03, 0x3f8673ab, 0x3fdb7705 },
  { 0x6fd0ef03, 0x4f8673ab, 0x7f800000 },
  { 0x20d0ef03, 0x1f0673ab, 0x006dbb83 },
  { 0x3fd0ef03, 0x3f798c55, 0x3fcbab02 },
  { 0x6fd0ef03, 0x4f798c55, 0x7f800000 },
  { 0x20d0ef03, 0x1ef98c55, 0x0065d581 },
  { 0x3fdd1181, 0x3f8ad17f, 0x3fefc0b1 },
  { 0x6fdd1181, 0x4f8ad17f, 0x7f800000 },
  { 0x20dd1181, 0x1f0ad17f, 0x0077e058 },
  { 0x3fdd1181, 0x3f752e81, 0x3fd3b9e9 },
  { 0x6fdd1181, 0x4f752e81, 0x7f800000 },
  { 0x20dd1181, 0x1ef52e81, 0x0069dcf5 },
  { 0x3f92efc6, 0x3fa00000, 0x3fb7abb8 },
  { 0x6f92efc6, 0x4fa00000, 0x7f800000 },
  { 0x2092efc6, 0x1f200000, 0x005bd5dc },
  { 0x3fdcefe6, 0x3f400000, 0x3fa5b3ec },
  { 0x6fdcefe6, 0x4f400000, 0x7f800000 },
  { 0x20dcefe6, 0x1ec00000, 0x0052d9f6 },
  { 0x3fad6507, 0x3fa2f8b7, 0x3fdcc4c9 },
  { 0x6fad6507, 0x4fa2f8b7, 0x7f800000 },
  { 0x20ad6507, 0x1f22f8b7, 0x006e6264 },
  { 0x3fad6507, 0x3f62f8b7, 0x3f99bba6 },
  { 0x6fad6507, 0x4f62f8b7, 0x7f800000 },
  { 0x20ad6507, 0x1ee2f8b7, 0x004cddd3 },
  { 0x3fbfde6b, 0x3f8721bd, 0x3fca8f27 },
  { 0x6fbfde6b, 0x4f8721bd, 0x7f800000 },
  { 0x20bfde6b, 0x1f0721bd, 0x00654794 },
  { 0x3fbfde6b, 0x3f4721bd, 0x3f953f2e },
  { 0x6fbfde6b, 0x4f4721bd, 0x7f800000 },
  { 0x20bfde6b, 0x1ec721bd, 0x004a9f97 },
  { 0x3ff40db4, 0x3f400000, 0x3fb70a47 },
  { 0x6ff40db4, 0x4f400000, 0x7f800000 },
  { 0x20f40db4, 0x1ec00000, 0x005b8524 },
  { 0x3ff40db4, 0x3f600000, 0x3fd58bfe },
  { 0x6ff40db4, 0x4f600000, 0x7f800000 },
  { 0x20f40db4, 0x1ee00000, 0x006ac5ff },
  { 0x3f9e20d3, 0x3f90c8a5, 0x3fb2dccc },
  { 0x6f9e20d3, 0x4f90c8a5, 0x7f800000 },
  { 0x209e20d3, 0x1f10c8a5, 0x00596e66 },
  { 0x3f9e20d3, 0x3fc00000, 0x3fed313c },
  { 0x6f9e20d3, 0x4fc00000, 0x7f800000 },
  { 0x209e20d3, 0x1f400000, 0x0076989e },
  { 0x3f9e20d3, 0x3f50c8a5, 0x3f80f69b },
  { 0x6f9e20d3, 0x4f50c8a5, 0x7f800000 },
  { 0x209e20d3, 0x1ed0c8a5, 0x00407b4d },
  { 0x3f82e641, 0x3f8fd63f, 0x3f931856 },
  { 0x6f82e641, 0x4f8fd63f, 0x7f800000 },
  { 0x2082e641, 0x1f0fd63f, 0x00498c2b },
  { 0x3f9a1901, 0x3f96e701, 0x3fb5ab68 },
  { 0x6f9a1901, 0x4f96e701, 0x7f800000 },
  { 0x209a1901, 0x1f16e701, 0x005ad5b4 },
  { 0x3fa21aa1, 0x3f7c4961, 0x3f9fc0ae },
  { 0x6fa21aa1, 0x4f7c4961, 0x7f800000 },
  { 0x20a21aa1, 0x1efc4961, 0x004fe057 },
  { 0x3fcd0767, 0x3f782457, 0x3fc6bc47 },
  { 0x6fcd0767, 0x4f782457, 0x7f800000 },
  { 0x20cd0767, 0x1ef82457, 0x00635e23 },
  { 0x3fb875e1, 0x3f968e21, 0x3fd8f6f6 },
  { 0x6fb875e1, 0x4f968e21, 0x7f800000 },
  { 0x20b875e1, 0x1f168e21, 0x006c7b7b },
  { 0x3fc2f0d7, 0x3f5efd19, 0x3fa9cd95 },
  { 0x6fc2f0d7, 0x4f5efd19, 0x7f800000 },
  { 0x20c2f0d7, 0x1edefd19, 0x0054e6cb },
  { 0x7f7ffffe, 0x3f800001, 0x7f800000 },
  { 0x00000003, 0xc00fffff, 0x80000007 },
  { 0x00000003, 0x400fffff, 0x00000007 },
  { 0x80000003, 0xc00fffff, 0x00000007 },
  { 0x80000003, 0x400fffff, 0x80000007 },
  { 0x00000003, 0xc00ffffd, 0x80000007 },
  { 0x00000003, 0x400ffffd, 0x00000007 },
  { 0x80000003, 0xc00ffffd, 0x00000007 },
  { 0x80000003, 0x400ffffd, 0x80000007 },
  { 0x3e00007f, 0x017c0000, 0x003f003f },
  { 0xcf7fff00, 0xc0ffff00, 0x50fffe00 },
  { 0x3fdf7f00, 0x3fffff00, 0x405f7e21 },
  { 0x19b92144, 0x1a310000, 0x00000001 },
  { 0x19ffc008, 0x1a002004, 0x00000001 },
  { 0x7f7ffff0, 0xc0000008, 0xff800000 },

  // Tests that do depend on Arm NaN policy
  { 0x00000000, 0x7fad4be3, 0x7fed4be3 },
  { 0x00000000, 0x7fdf48c7, 0x7fdf48c7 },
  { 0x00000001, 0x7f970eba, 0x7fd70eba },
  { 0x00000001, 0x7fc35716, 0x7fc35716 },
  { 0x007fffff, 0x7fbf52d6, 0x7fff52d6 },
  { 0x007fffff, 0x7fc7a2df, 0x7fc7a2df },
  { 0x3f800000, 0x7f987a85, 0x7fd87a85 },
  { 0x3f800000, 0x7fc50124, 0x7fc50124 },
  { 0x7f7fffff, 0x7f95fd6f, 0x7fd5fd6f },
  { 0x7f7fffff, 0x7ffc28dc, 0x7ffc28dc },
  { 0x7f800000, 0x00000000, 0x7fc00000 },
  { 0x7f800000, 0x7f8dd790, 0x7fcdd790 },
  { 0x7f800000, 0x7fd2ef2b, 0x7fd2ef2b },
  { 0x7f800000, 0x80000000, 0x7fc00000 },
  { 0x7f99b09d, 0x00000000, 0x7fd9b09d },
  { 0x7f93541e, 0x00000001, 0x7fd3541e },
  { 0x7f9fc002, 0x007fffff, 0x7fdfc002 },
  { 0x7fb5db77, 0x3f800000, 0x7ff5db77 },
  { 0x7f9f5d92, 0x7f7fffff, 0x7fdf5d92 },
  { 0x7fac7a36, 0x7f800000, 0x7fec7a36 },
  { 0x7fb42008, 0x7fb0ee07, 0x7ff42008 },
  { 0x7f8bd740, 0x7fc7aaf1, 0x7fcbd740 },
  { 0x7f9bb57b, 0x80000000, 0x7fdbb57b },
  { 0x7f951a78, 0x80000001, 0x7fd51a78 },
  { 0x7f9ba63b, 0x807fffff, 0x7fdba63b },
  { 0x7f89463c, 0xbf800000, 0x7fc9463c },
  { 0x7fb63563, 0xff7fffff, 0x7ff63563 },
  { 0x7f90886e, 0xff800000, 0x7fd0886e },
  { 0x7fe8c15e, 0x00000000, 0x7fe8c15e },
  { 0x7fe915ae, 0x00000001, 0x7fe915ae },
  { 0x7ffa9b42, 0x007fffff, 0x7ffa9b42 },
  { 0x7fdad0f5, 0x3f800000, 0x7fdad0f5 },
  { 0x7fd10dcb, 0x7f7fffff, 0x7fd10dcb },
  { 0x7fd08e8a, 0x7f800000, 0x7fd08e8a },
  { 0x7fc3a9e6, 0x7f91a816, 0x7fd1a816 },
  { 0x7fdb229c, 0x7fc26c68, 0x7fdb229c },
  { 0x7fc9f6bb, 0x80000000, 0x7fc9f6bb },
  { 0x7ffa178b, 0x80000001, 0x7ffa178b },
  { 0x7fef2a0b, 0x807fffff, 0x7fef2a0b },
  { 0x7ffc885b, 0xbf800000, 0x7ffc885b },
  { 0x7fd26e8c, 0xff7fffff, 0x7fd26e8c },
  { 0x7fc55329, 0xff800000, 0x7fc55329 },
  { 0x80000000, 0x7f800000, 0x7fc00000 },
  { 0x80000000, 0x7fa833ae, 0x7fe833ae },
  { 0x80000000, 0x7fc4df63, 0x7fc4df63 },
  { 0x80000000, 0xff800000, 0x7fc00000 },
  { 0x80000001, 0x7f98827d, 0x7fd8827d },
  { 0x80000001, 0x7fd7acc5, 0x7fd7acc5 },
  { 0x807fffff, 0x7fad19c0, 0x7fed19c0 },
  { 0x807fffff, 0x7ffe1907, 0x7ffe1907 },
  { 0xbf800000, 0x7fa95487, 0x7fe95487 },
  { 0xbf800000, 0x7fd2bbee, 0x7fd2bbee },
  { 0xff7fffff, 0x7f86ba21, 0x7fc6ba21 },
  { 0xff7fffff, 0x7feb00d7, 0x7feb00d7 },
  { 0xff800000, 0x7f857fdc, 0x7fc57fdc },
  { 0xff800000, 0x7fde0397, 0x7fde0397 },
};

float
make_float (uint32_t x)
{
  float r;
  memcpy (&r, &x, sizeof (r));
  return r;
}

uint32_t
unmake_float (float x)
{
  uint32_t r;
  memcpy (&r, &x, sizeof (r));
  return r;
}

int
main (void)
{
  bool failed = false;

  for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
    {
      const struct test *t = &tests[i];

#ifdef USE_NATIVE_ARITHMETIC
      /* If you compile with USE_NATIVE_ARITHMETIC defined, the same
       * set of tests will be run using the toolchain's built in float
       * arithmetic, instead of calling arm_fp_fmul. */
      float in1 = make_float (t->in1);
      float in2 = make_float (t->in2);
      float out = in1 * in2;
      uint32_t outbits = unmake_float (out);
#else
      extern uint32_t arm_fp_fmul(uint32_t, uint32_t);
      uint32_t outbits = arm_fp_fmul(t->in1, t->in2);
#endif

      if (outbits != t->out)
	{
	  printf ("FAIL: fmul(%08" PRIx32 ", %08" PRIx32 ") -> %08" PRIx32
		  ", expected %08" PRIx32 "\n",
		  t->in1, t->in2, outbits, t->out);
	  failed = true;
	}
    }

  if (!failed)
    printf ("all passed\n");

  return failed;
}
